package com.sxz.sbs.module.amortize;

import android.content.Intent;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.sxz.sbs.R;
import com.sxz.sbs.applibrary.state.StateLayout;
import com.sxz.sbs.base.BaseActivity;
import com.sxz.sbs.base.BasePresenter;
import com.sxz.sbs.module.amortize.adapter.SelectBankAdapter;
import com.sxz.sbs.widget.CommonTitle;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 选择银行
 */
public class SelectBankActivity extends BaseActivity {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.stateLayout)
    StateLayout stateLayout;
    @BindView(R.id.refreshLayout)
    SwipeRefreshLayout refreshLayout;
    private SelectBankAdapter adapter;
    private List<AmortizeBankBean> data = new ArrayList<>();
    @Override
    protected void init() {
        new CommonTitle.Builder(this).setTitle("选择银行").build().show();
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        Intent intent = getIntent();
        data =  intent.getParcelableArrayListExtra("bank");
        adapter = new SelectBankAdapter(data);
        recyclerView.setAdapter(adapter);
        refreshLayout.setColorSchemeResources(R.color.color_main);
        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                refreshLayout.setRefreshing(false);
            }
        });
        recyclerView.addOnItemTouchListener(new OnItemClickListener() {
            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent1 = new Intent();
                intent1.putExtra("bank_result",data.get(position));
                setResult(1011,intent1);
                finish();
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_select_bank;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

}
